package user

import (
	"API/client"
	"API/request"
	"API/response"
	"github.com/gin-gonic/gin"
	user "user_server/proto"
)

func RealNameHandler(c *gin.Context) {
	var req request.RealNameRequest
	if err := c.ShouldBind(&req); err != nil {
		response.CurrencyErrResponse(c, 400, err.Error())
		return
	}
	userId := c.GetUint("userId")
	res, err := client.UserRealName(c, &user.UserRealNameReq{
		UserId:   int64(userId),
		RealName: req.RealName,
		CardId:   req.IDCard,
	})
	if err != nil {
		response.CurrencyErrResponse(c, 500, err.Error())
		return
	}
	response.CurrencySuccessResponse(c, res.Success, nil)
}
